home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Palettes / MiscTableScroll / MiscListTracker.M < prev    next >
Encoding:
Text File  |  1996-02-11  |  3.2 KB  |  109 lines

  1. //=============================================================================
  2. //
  3. //        Copyright (C) 1995 by Paul S. McCarthy and Eric Sunshine.
  4. //                Written by Paul S. McCarthy and Eric Sunshine.
  5. //                            All Rights Reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //        This object is included in the MiscKit by permission from the authors
  10. //        and its use is governed by the MiscKit license, found in the file
  11. //        "License.rtf" in the MiscKit distribution.    Please refer to that file
  12. //        for a list of all applicable permissions and restrictions.
  13. //        
  14. //=============================================================================
  15. //-----------------------------------------------------------------------------
  16. // MiscListTracker.M
  17. //
  18. //        List-mode selection tracking.
  19. //
  20. //-----------------------------------------------------------------------------
  21. //-----------------------------------------------------------------------------
  22. // $Id: MiscListTracker.M,v 1.1 95/09/27 12:21:21 zarnuk Exp $
  23. // $Log:        MiscListTracker.M,v $
  24. //    Revision 1.1  95/09/27    12:21:21  zarnuk
  25. //    Initial revision
  26. //    
  27. //-----------------------------------------------------------------------------
  28. #import "MiscListTracker.h"
  29. #import "MiscSparseSet.h"
  30. #import "MiscTableBorder.h"
  31.  
  32.  
  33. @implementation MiscListTracker
  34.  
  35. //-----------------------------------------------------------------------------
  36. // setAnchor:
  37. //-----------------------------------------------------------------------------
  38. - (void) setAnchor: (MiscCoord_V) pos
  39.     {
  40.     anchor = pos;
  41.     set->setCursor( pos );
  42.     }
  43.  
  44.  
  45. //-----------------------------------------------------------------------------
  46. // mouseDown:atPos:
  47. //-----------------------------------------------------------------------------
  48. - (void) mouseDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
  49.     {
  50.     if (event->flags & NX_ALTERNATEMASK)
  51.         {
  52.         int cursor = set->getCursor();
  53.         if (cursor < 0 || cursor >= border->count())
  54.             cursor = 0;
  55.         set->add( cursor, pos );
  56.         anchor = cursor;
  57.         set->setCursor( pos );
  58.         }
  59.     else if (event->flags & NX_SHIFTMASK)
  60.         {
  61.         set->toggle( pos );
  62.         [self setAnchor: pos];
  63.         }
  64.     else
  65.         {
  66.         set->empty();
  67.         set->add( pos );
  68.         [self setAnchor: pos];
  69.         }
  70.     }
  71.  
  72.  
  73. //-----------------------------------------------------------------------------
  74. // mouseDragged:atPos:
  75. //-----------------------------------------------------------------------------
  76. - (void) mouseDragged: (NXEvent const*) event atPos: (MiscCoord_V) pos
  77.     {
  78.     if (pos < 0) pos = 0;
  79.     if (pos >= border->count()) pos = border->count() - 1;
  80.  
  81.     int cursor = set->getCursor();
  82.     if (pos != cursor)
  83.         {
  84.         set->remove( anchor, cursor );
  85.         set->add( anchor, pos );
  86.         set->setCursor( pos );
  87.         }
  88.     }
  89.  
  90.  
  91. //-----------------------------------------------------------------------------
  92. // mouseUp:atPos:
  93. //-----------------------------------------------------------------------------
  94. - (void) mouseUp: (NXEvent const*) event atPos: (MiscCoord_V) pos
  95.     {
  96.     }
  97.  
  98.  
  99. //-----------------------------------------------------------------------------
  100. // keyDown:atPos:
  101. //-----------------------------------------------------------------------------
  102. - (void) keyDown: (NXEvent const*) event atPos: (MiscCoord_V) pos
  103.     {
  104.     set->toggle( pos );
  105.     [self setAnchor: pos];
  106.     }
  107.  
  108. @end
  109.